<?php
/**
 * Created by PhpStorm.
 * User: 王松
 * Time: 2017/10/21 21:46
 */

namespace App\Project\Search\Decorator;

use App\Project\Search\Decorator;

class PastDecorator extends Decorator
{
    protected $table = 'st_medical_illnesshistory';

    protected $prefix = 'past';

    /**
     * @return \Illuminate\Database\Query\Builder
     */
    public function getBuilder()
    {
        return $this->fillBuilder([
            $this->table,
            'st_medical_records.id',
            $this->table . '.record_id'
        ]);
    }

    public function getAccessField()
    {
        return [
            'fw'   => 'fat.weight',                  //  肥胖
            'hyt'  => 'hypertension.time',           //  高血压
            'ct'   => 'coronary_disease.time',       //  冠心病
            'ht'   => 'hyperuricemia.time',          //  高尿酸血证
            'hat'  => 'hyperlipidemia.time',         //  高脂血症
            'flt'  => 'fatty_liver.time',            //  脂肪肝
            'hst'  => 'hepatitis.type',              //  肝炎类型
            'pa'   => 'pancreatitis.acute',          //  胰腺炎 急性
            'pc'   => 'pancreatitis.chronic',        //  胰腺炎 慢性
            'pot'  => 'pancreatic_operation.time',   //  胰腺炎 手术史
            'rt'   => 'renal.time',                  //  肾功能不全
            'cit'  => 'cerebral_infarction.time',    //  脑梗死
            'pcos' => 'pcos.time',                   //  多囊卵巢综合征
            'trt'  => 'trauma.time',                 //  外伤手术史
            'tt'   => 'transfusion.times',           //  输血史
            'iit'  => 'irritability.items',          //  过敏史
            'tht'  => 'thyroid.type',                //  甲状腺功能
            'cot'  => 'contagion.time',              //  传染病史
        ];
    }

    public function getAccessOperator()
    {
        return [
            'fw'   => ['ex'],
            'hyt'  => ['ex'],
            'ct'   => ['ex'],
            'ht'   => ['ex'],
            'hat'  => ['ex'],
            'flt'  => ['ex'],
            'hst'  => ['ex'],
            'pa'   => ['ex'],
            'pc'   => ['ex'],
            'pot'  => ['ex'],
            'rt'   => ['ex'],
            'cit'  => ['ex'],
            'pcos' => ['ex'],
            'trt'  => ['ex'],
            'tt'   => ['ex'],
            'iit'  => ['ex'],
            'tht'  => ['eq'],
            'cot'  => ['ex'],
        ];
    }
}